/**
 * 
 */
package com.lazyshopkeeper.front.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lazyshopkeeper.front.persistence.UserMapper;
import com.lazyshopkeeper.front.service.IUserService;
import com.taobao.api.domain.User;

/**
 * @author xuyuqi
 *
 */
@Service("localUserService")
public class UserService implements IUserService {

	@Autowired
	private UserMapper userMapper;
	
	/* (non-Javadoc)
	 * @see com.lazyshopkeeper.front.service.IUserService#getUser(java.lang.String)
	 */
	@Override
	public User getUser(String nick) {
		if(nick == null) return null;
		return userMapper.getUser(nick);
	}

	@Transactional
	@Override
	public boolean saveNewUser(User user) {
		if(user == null) return false;
		userMapper.saveNewUser(user);
		userMapper.saveUserCredit(user.getUserId(), user.getSellerCredit());
		return true;
	}

}
